require(["common", "jQuery", "coAjax", "queryString", "href", "hash_routie"], function(jSouper, $, coAjax, QueryString, href, hash_routie) {
	var _num = 10;
	var _page = 0;
	hash_routie.on("comment", function() {
		App.set('title', '评价管理');

		App.set("thisPage", 4);
		function _load_eval_page(num, page) {
			coAjax.get(appConfig.user.evaluation_with_page_info, {
				num: num,
				page: page
			}, function(result) {
				var info = result.result;
				console.log("user.evaluations", info.evaluations);
				App.set("user.evaluations", info.evaluations);
				page_info = {
					total_num: info.total_num,
					total_page: info.total_page,
					page: info.page,
					num: info.num
				};
				page_info._number_list = [];
				page_info._number_list.length = info.total_page;
				App.set("$Cache.user.eval.page_info", page_info);
			});
		};

		//分页功能

		// var queryString = new QueryString(location.hash);
		// _num = queryString.get("num") || _num;
		// _page = queryString.get("page") || _page;
		_load_eval_page(_num, _page);

		// coAjax.get(appConfig.user.evaluation,function (result) {
		// 	console.log("user.evaluations",result.result);
		// 	App.set("user.evaluations",result.result);
		// });
		//接口实现，回复评论
		App.set("$Event.comment.reply", function(e, vm) {
			var _reply_content = $.trim(vm.get("_reply_content"));
			if (!_reply_content) {
				return
			};
			coAjax.post(appConfig.user.add_comment, {
				reply_id: vm.get("_id"),
				content: _reply_content
			}, function(result) {
				var comments = vm.get("comments");
				comments.unshift(result.result);
				vm.set("comments", comments)
			});
			vm.set("_reply_content", "");
		});
	});
});